<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
var erfen = function(nums,num){
    nums = maopao(nums)
    let low = 0
    let high = nums.length-1
    while( low<=high ){
        let mid = Math.floor( (low+high) / 2 )
        let element = nums[mid]
        if( element>num ){
            high = mid-1
        }
        else if( element<num ){
            low = mid+1
        }
        else{
            return ('找到在第'+(mid+1)+'个位置上')
        }
    }
    return '没找到'
}


var maopao = function (nums){
    for( var i = 0; i<nums.length-1 ;i++ ){
        for(var j = 0; j<nums.length-1-i ; j++ ){
            if(nums[j]>nums[j+1]){
                [nums[j],nums[j+1]]=[nums[j+1],nums[j]]
            }
        }
    }
    return nums
}
nums=[5,4,3,2,1,4,11,12,55,333,223,455,44,2211,99]
num = 4
console.log(erfen(nums,num))
    </script>
</body>
</html>